namespace Management.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class BuildConnectionBeteenUserAndRole : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Admins", "RoleID", "dbo.Roles");
            DropIndex("dbo.Admins", new[] { "RoleID" });
            CreateIndex("dbo.AdminRoles", "RoleID");
            CreateIndex("dbo.AdminRoles", "AdminID");
            AddForeignKey("dbo.AdminRoles", "AdminID", "dbo.Admins", "AdminID", cascadeDelete: true);
            AddForeignKey("dbo.AdminRoles", "RoleID", "dbo.Roles", "RoleID", cascadeDelete: true);
            DropColumn("dbo.Admins", "RoleID");
        }
        
        public override void Down()
        {
            AddColumn("dbo.Admins", "RoleID", c => c.Int(nullable: false));
            DropForeignKey("dbo.AdminRoles", "RoleID", "dbo.Roles");
            DropForeignKey("dbo.AdminRoles", "AdminID", "dbo.Admins");
            DropIndex("dbo.AdminRoles", new[] { "AdminID" });
            DropIndex("dbo.AdminRoles", new[] { "RoleID" });
            CreateIndex("dbo.Admins", "RoleID");
            AddForeignKey("dbo.Admins", "RoleID", "dbo.Roles", "RoleID", cascadeDelete: true);
        }
    }
}
